//
//  MusicCD04Widget.swift
//  TimMusic
//
//  Created by nkl on 2024/10/17.
//

import Foundation
import SwiftUI

struct Small_MusicCD02_02: View {
    var model: ControlMusicModel

    var body: some View {
        ZStack {
            if let data = model.imageData, let uiImage = UIImage(data: data),!model.isStatic {
                Image(uiImage: uiImage).resizable().ignoresSafeArea()
            } else {
                Image("ic_small_placeholder").resizable().ignoresSafeArea()
            }
            VStack {
                Text(model.title)
                    .font(.system(size: 16).bold())
                    .multilineTextAlignment(.center)
                    .lineLimit(2)
                    .foregroundColor(.white)
                Spacer().frame(height: 14)
                Text(model.auth).font(.system(size: 12))
                    .foregroundColor(.white.opacity(0.6))
                if model.isPlay {
                    Image("ic_widget_pause").padding(.top, 30)
                        .modifier(AppClickModifier(urlString: "timMusic://musicControl?option=\(OptionType.pause.rawValue)", isStatic: model.isStatic))
                } else {
                    Image("ic_widget_play").padding(.top, 30)
                        .modifier(AppClickModifier(urlString: "timMusic://musicControl?option=\(OptionType.play.rawValue)", isStatic: model.isStatic))
                }
            }.padding(.horizontal)
        }
    }
}
